#PM2.5 leaflets
PM25_1990_leaflet
PM25_2017_leaflet
PM25_change_leaflet
DALY_1990_leaflet
DALY_2017_leaflet
DALY_change_leaflet
#is there a way to look at how both variables change in relation to one another over time,
#in a more broader term and in a single visualization?

g <- ggplot(data_joined, aes(PM25exposure , DALY, color = country))+
  geom_point(alpha = 0.7, show.legend = FALSE)+
  scale_size(range = c(2, 12))+
  theme_classic()+
  labs(title = 'Year: {round(frame_time, 0)}', x = 'PM 2.5', y = 'DALY per 1K')+
  transition_time(year)+
  ease_aes('linear')

animate(g, duration = 20, fps = 20, width = 400, height = 400, renderer = gifski_renderer())

#anim_save("PM2.5 vs. DALY.gif")
countrylist_index <- floor(runif(10, min = 0, max = nrow(data_joined)))
countrylist <- rep(c("country"), 10)

for (i in 1:length(countrylist_index)){
  countrylist[i] <- data_joined$country[countrylist_index[i]]
}

data_joined <- subset(data_joined, country %in% countrylist)


gdaly <- ggplotly(ggplot(data = data_joined, mapping = aes(x = year, y = DALY, color = country)) +
    geom_line() +
  scale_y_continuous(trans = "log10")+
    labs(
      title = "Disability-Adjusted Life (DALY) Year per 1K",
      subtitle = "1990 to 2017",
      y = "DALY",
      x = "Year")+
    theme_classic())

gexposure <- ggplotly(ggplot(data = data_joined, mapping = aes(x = year, y = PM25exposure, color = country)) +
     geom_line() +
     labs(
       title = "Population exposure to PM 2.5",
       subtitle = "1990 to 2017",
       y = "Population exposure ",
       x = "Year")+
    theme_classic())
gdaly
gexposure